home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Programming / VisualBuilder / source / DropObjClass.c < prev    next >
C/C++ Source or Header  |  1997-08-29  |  2KB  |  91 lines

  1. #include "DropObjClass.h"
  2.       
  3. ULONG DropObj_DragQuery(struct IClass *cl,Object *obj,struct MUIP_DragQuery *msg)
  4. {
  5.   return(MUIV_DragQuery_Accept);
  6. }
  7.  
  8. ULONG DropObj_DragDrop(struct IClass *cl,Object *obj,struct MUIP_DragDrop *msg)
  9. { Object *group, *new, *win, *app;
  10.   int type, foo;
  11.         
  12.   get(msg->obj,MUIA_UserData,&type);
  13.   get(obj,MUIA_WindowObject,&win);
  14.     
  15.   /* We are dropping an object from the toolbox, add it */
  16.   if(type<MUIGroup && type != NULL)
  17.   
  18.   { new=CreateDropObj(type);
  19.  
  20.     if(new)
  21.     { get(obj,MUIA_Parent,&group);
  22.  
  23.       if(group!=NULL)
  24.       { get(obj,MUIA_UserData,&type);
  25.  
  26.         if(type == MUIGroup)
  27.         /* Insert before or add to this group */
  28.         { foo = MUI_Request(a->App,win,0,"VB request","*_Before|_In",
  29.                 "Insert the new object before\nor in this group?");
  30.  
  31.           if(foo==0)
  32.             Group_Append(new,obj);
  33.           else
  34.             Group_Insert(new,obj,group);
  35.         }
  36.         else
  37.           Group_Insert(new,obj,group);
  38.       }
  39.     }
  40.   }
  41.   else
  42.   /* We dropped an existing object, move it */
  43.   { 
  44.     get(obj,MUIA_Parent,&group);
  45.  
  46.     /* Don't drop on ourselves or on a child*/
  47.     if(obj!=msg->obj && group!=msg->obj)
  48.     { if(group!=NULL)
  49.       { get(obj,MUIA_UserData,&type);
  50.         if(type == MUIGroup)
  51.         { foo = MUI_Request(a->App,win,0,"VB request","*_Before|_In",
  52.                 "Move this object before\nor in this group?");
  53.           Group_Remove(msg->obj);
  54.           if(foo==0)
  55.             Group_Append(msg->obj,obj);
  56.           else
  57.             Group_Insert(msg->obj,obj,group);
  58.         }
  59.         else
  60.           Group_Move(msg->obj,obj);
  61.       }
  62.     }
  63.     else
  64.     { /* We've been dropped on ourselves, update the objects window */ 
  65.       if(obj==msg->obj)
  66.       { 
  67.         get(msg->obj,MUIA_WindowObject,&win);
  68.         get(win,MUIA_ApplicationObject,&app);
  69.        
  70.         set(win,MUIA_Window_ActiveObject,msg->obj);
  71.         set(app,MUIA_UserData,msg->obj);
  72.  
  73.         UpdateObjectsWindow(obj);
  74.       }
  75.     }
  76.   }
  77.   
  78.   return(0);
  79. }
  80.  
  81. SAVEDS ASM ULONG DropObj_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  82. {
  83.   switch (msg->MethodID)
  84.   {
  85.     case MUIM_DragQuery: return(DropObj_DragQuery(cl,obj,(APTR)msg));
  86.     case MUIM_DragDrop : return(DropObj_DragDrop (cl,obj,(APTR)msg));
  87.   }
  88.   return(DoSuperMethodA(cl,obj,msg));
  89. }
  90.  
  91.